# Generate the dataset that can be directly passed to model by using Tensorflow
# functions.

def get_dataset(normalization):
    import tensorflow as tf
    from Preprocessing_data import train_data_generator
    from Global_variable_setting import training_dataset_length, size_of_batch

    data = train_data_generator(normalization)
    dataset = tf.data.Dataset.from_generator(lambda: iter(data), output_types=(tf.float64, tf.float64))
    ds_train = dataset.take(training_dataset_length)  # 组建训练集
    ds_test = dataset.skip(training_dataset_length)  # 组建测试集
    # 以下语句对训练数据库作进一步的处理，使之成为可以直接输入到模型中的数据库
    ds_train = ds_train.cache()
    ds_train = ds_train.batch(size_of_batch)    # 这一段去掉了对于训练数据库来说原本应该有的“shuffle”阶段， because this function has completed in "Preprocessing_data.py"
    ds_train = ds_train.prefetch(tf.data.experimental.AUTOTUNE)
    # 以下语句对测试数据库作进一步的处理，使之成为可以直接输入到模型中的数据库
    ds_test = ds_test.cache()
    ds_test = ds_test.batch(size_of_batch)
    ds_test = ds_test.prefetch(tf.data.experimental.AUTOTUNE)  # 对于测试数据库的处理在此结束
    return ds_train, ds_test
